home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / nihcl-30.lha / nihcl-3.0 / lib / Stack.h < prev    next >
C/C++ Source or Header  |  1990-05-19  |  2KB  |  67 lines

  1. #ifndef    STACK_H
  2. #define    STACK_H
  3.  
  4. /*$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/lib/RCS/Stack.h,v 3.0 90/05/20 00:21:28 kgorlen Rel $*/
  5.  
  6. /* Stack.h -- declarations for class Stack
  7.  
  8.     THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
  9.     "UNITED STATES GOVERNMENT WORK".  IT WAS WRITTEN AS A PART OF THE
  10.     AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE.  THIS MEANS IT
  11.     CANNOT BE COPYRIGHTED.  THIS SOFTWARE IS FREELY AVAILABLE TO THE
  12.     PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
  13.     RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
  14.  
  15. Author:
  16.     K. E. Gorlen
  17.     Computer Systems Laboratory, DCRT
  18.     National Institutes of Health
  19.     Bethesda, MD 20892
  20.  
  21. $Log:    Stack.h,v $
  22.  * Revision 3.0  90/05/20  00:21:28  kgorlen
  23.  * Release for 1st edition.
  24.  * 
  25. */
  26.  
  27. #include "OrderedCltn.h"
  28.  
  29. class Stack: public SeqCltn {
  30.     DECLARE_MEMBERS(Stack);
  31.     OrderedCltn contents;
  32. protected:        // storer() functions for object I/O
  33.     virtual void storer(OIOofd&) const;
  34.     virtual void storer(OIOout&) const;
  35. public:
  36.     Stack(unsigned size =DEFAULT_CAPACITY);
  37.     Stack(const Stack&);
  38.     bool operator==(const Stack& s) const
  39.         { return contents == s.contents; }
  40.     bool operator!=(const Stack& s)    const { return !(*this==s); }
  41.     void operator=(const Stack& s)    { contents = s.contents; }
  42.     Object*& operator[](int i)    { return contents.at(size()-i-1); }
  43.     const Object *const& operator[](int i) const    { return contents.at(size()-i-1); }
  44.     void push(Object& ob)        { contents.addLast(ob); }
  45.     Object* pop()            { return contents.removeLast(); }
  46.     Object* top() const        { return contents.last(); }
  47.     virtual Object* add(Object& ob);
  48.     virtual Object*& at(int i);
  49.     virtual const Object *const& at(int i) const;
  50.     virtual unsigned capacity() const;
  51.     virtual void deepenShallowCopy();
  52.     virtual unsigned hash() const;
  53.     virtual bool isEmpty() const;
  54.     virtual Object* last() const;
  55.     virtual void reSize(unsigned newSize);
  56.     virtual void removeAll();
  57.     virtual Object* removeLast();
  58.     virtual unsigned size() const;
  59. private:                // shouldNotImplement();
  60.     virtual void atAllPut(Object& ob);
  61.     virtual int indexOfSubCollection(const SeqCltn& cltn, int start=0) const;
  62.     virtual Object* remove(const Object&);
  63.     virtual void replaceFrom(int start, int stop, const SeqCltn& replacement, int startAt =0);
  64. };
  65.  
  66. #endif
  67.